package com.example.a313ldy.yuejian_17.Fragment.TrainFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.a313ldy.yuejian_17.Adapter.TrainAdapter;
import com.example.a313ldy.yuejian_17.Bean.Train;
import com.example.a313ldy.yuejian_17.Listener.TrainListener;
import com.example.a313ldy.yuejian_17.Model.TrainModel;
import com.example.a313ldy.yuejian_17.R;

import java.util.List;

/**
 * Created by LDY on 2017/11/7.
 */

public class AllFragment extends Fragment implements TrainListener<List<Train>> {


    RecyclerView recyclerView_Trainlist;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View  v = inflater.inflate(R.layout.fragment_all,null);
        recyclerView_Trainlist = (RecyclerView) v.findViewById(R.id.id_fragment_main);
        recyclerView_Trainlist.setLayoutManager(new LinearLayoutManager(getActivity()));


        TrainModel TrainModel = new TrainModel();
        TrainModel.TrainData(this,4);
        return v;
    }




    @Override
    public void onResponse(List<Train> train) {

        TrainAdapter adapter = new TrainAdapter(getActivity(),train);
        recyclerView_Trainlist.setAdapter(adapter);
    }

    @Override
    public void onFail(String msg) {
        System.out.println("+++++" + "失败率");
    }



}
